package com.cium.aqie.objectOriented.delegate

import kotlin.reflect.KProperty

/**
 * @Function: 实现getValue方法 就可以作为代理
 * @Author: aqie
 * @Date: 2019/8/31 18:03
 */
class X{
    private var value: String? = null

    /**
     * 只代理String
     */
    operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
        println("getValue: $thisRef -> ${property.name}")
        return value?: ""
    }

    operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String){
        println("setValue, $thisRef -> ${property.name} = $value")
        this.value = value
    }
}